from tenacity import retry, stop_after_attempt, wait_exponential
import requests

@retry(
    stop=stop_after_attempt(3),  # 最多重试3次
    wait=wait_exponential(multiplier=1, min=4, max=10)  # 指数退避等待
)
def fetch_data():
    response = requests.get("https://www.basidu.com/sss")
    if response.status_code != 200:
        raise Exception("API请求失败")
    return response.text


rs=fetch_data()
print(rs)